package cn.hxzy.course.service.impl;

import cn.hxzy.common.domain.Task;
import cn.hxzy.common.domain.vo.TaskVo;
import cn.hxzy.course.mapper.TaskMapper;
import cn.hxzy.course.service.TaskService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author niuyi
 * @since 2024-06-22
 */
@Service
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService {




    @Autowired
    private TaskMapper taskMapper;


    @Override
    public TaskVo selectTaskVo(Integer taskId) {
        return taskMapper.selectTaskVo(taskId);
    }

    @Override
    public List<Task> selectList(int taskId) {
        return null;
    }

    @Override
    public List<Task> selectTask(String taskName, Integer courseId) {
        List<Task> tasks = taskMapper.selectTask(taskName,courseId);
        if (tasks != null){
            return tasks;
        }
        return null;
    }

    @Override
    public double selectCount(Long courseId) {
        double num = taskMapper.selectCount(courseId);
        return num;
    }

    @Override
    public List<Task> getList(int sectionId) {
        List<Task> list = taskMapper.getList(sectionId);
        if (list != null){
            return list;
        }
        return null;
    }

    @Override
    public List<Task> selectTaskList(Integer sectionId) {
        QueryWrapper<Task> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("section_id",sectionId);
        List<Task> tasks = taskMapper.selectList(queryWrapper);
        if (tasks != null){
            return tasks;
        }
        return null;
    }

    @Override
    public int deleteTask(Integer taskId) {
        int i = taskMapper.deleteById(taskId);
        return i;
    }


}
